package com.java;

import java.util.Objects;

public class ObjectsAPI {
    static class Student {
        private String name = "SYX";
        private Integer age = 19;
        
        public Student() {}
        
        @Override
        public String toString() {
            return this.name + this.age;
        }
    }
    
    public static void main(String[] args) {
        // toString：将对象转为String
        System.out.println(Objects.toString(new Student())); // SYX19
        
        // equals：判断对象是否相同。默认比较地址值，重写后一般比较属性值
        System.out.println(Objects.equals(new Student(), new Student())); // false
        
        // deepEquals：深度判断对象内容是否相等
        
        // isNull：判断对象是否为空，为空返回true
        System.out.println(Objects.isNull(null)); // true
        System.out.println(Objects.isNull(new Student())); // false
        
        // nonNull：判断对象是否不为空，不为空返回true
        System.out.println(Objects.isNull(null)); // true
        System.out.println(Objects.isNull(new Student())); // false
    }
}
